from fastapi import FastAPI
import uvicorn

# 创建app对象
app = FastAPI()


# 路由函数（路径函数）
@app.get("/books/{book_id}/{book_name}")
# 指定book_id参数是int类型，book_name是字符串类型
async def get_book_by_id(book_id:int, book_name:str):
    return {"book_id": book_id, "book_name": book_name}

if __name__ == "__main__":
    uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)
